

module ethernet_tcp;

   logic                   clk                                    ;
   logic                   rst                                  ;
   logic                   rst_delay                              ;
   logic [2 : 0]           test_pattern                              ;
   logic                   user_tx_s_axis_tvalid                     ;
   logic [7 : 0]           user_tx_s_axis_tdata                      ;
   logic                   user_tx_s_axis_tready                     ;
   logic                   user_tx_s_axis_tlast                      ;
   logic [67: 0]           user_tx_s_axis_tuser                      ;
   logic                   user_rx_m_axis_tvalid                     ;
   logic [7 : 0]           user_rx_m_axis_tdata                      ;
   logic                   user_rx_m_axis_tlast                      ;
   logic [63: 0]           user_rx_m_axis_tuser                      ;
   logic [7 : 0]           gmii_rxdata                               ;
   logic                   gmii_rxvalid                              ;
   logic [7 : 0]           gmii_txdata                               ;
   logic                   gmii_txvalid                              ; 


    initial begin
        clk <= 0;
        forever begin
            #4ns;
            clk <= ~clk;
        end
    end

    initial begin
        rst <= 1;
        #100ns;
        @(posedge clk)
        #1ns;
        rst <= 0;
    end

    initial begin
        rst_delay <= 1;
        test_pattern <= 0;
        #2us;
        @(posedge clk);
        rst_delay <= 0;
        @(posedge clk);
        test_pattern <= 3;
        #10us;
    end











   test_pattern #(
      .TEST_DATA_LEN                   ( 16'd1472                        )
   )test_pattern_inst(
      .i_clk                           ( clk                         ),
      .i_rst                           ( rst_delay                   ),
      .i_test_pattern                  ( test_pattern                ),
      .m_axis_tvalid                   ( user_tx_s_axis_tvalid       ),
      .m_axis_tdata                    ( user_tx_s_axis_tdata        ),
      .m_axis_tready                   ( user_tx_s_axis_tready       ),
      .m_axis_tlast                    ( user_tx_s_axis_tlast        ),
      .m_axis_tuser                    ( user_tx_s_axis_tuser        ),
      .s_axis_tvalid                   ( user_rx_m_axis_tvalid       ),
      .s_axis_tdata                    ( user_rx_m_axis_tdata        ),
      .s_axis_tlast                    ( user_rx_m_axis_tlast        ),
      .s_axis_tuser                    ( user_rx_m_axis_tuser        )
   );

   /*-----------------------------------------------------------
                     ENTHERNET stack
   ------------------------------------------------------------*/
   ethernet_top #( 
      .SOURCE_PORT                     ( 16'd5001                    ),
      .SOURCE_IP                       ( {8'd192,8'd168,8'd7,8'd11}  ),
      .SOURCE_IP_MASK                  ( {8'd255,8'd255,8'd255,8'd0} ),
      .SOURCE_MAC                      ( 48'h11_22_33_44_55_66       ),
      .MAC_CRC_ON                      ( 1                           )
   )ethernet_top_inst(

      .i_clk                           ( clk                         ),
      .i_rst                           ( rst                        ),           
      .i_config_req                    ( 0),
      .i_config_source_port            ( 0),
      .i_config_source_ip              ( 0),
      .i_config_source_ip_mask         ( 0),
      .i_config_source_mac             ( 0),
      .user_tx_s_axis_tvalid           ( user_tx_s_axis_tvalid       ),
      .user_tx_s_axis_tdata            ( user_tx_s_axis_tdata        ),
      .user_tx_s_axis_tready           ( user_tx_s_axis_tready       ),
      .user_tx_s_axis_tlast            ( user_tx_s_axis_tlast        ),
      .user_tx_s_axis_tuser            ( user_tx_s_axis_tuser        ),
      .user_rx_m_axis_tvalid           ( user_rx_m_axis_tvalid       ),
      .user_rx_m_axis_tdata            ( user_rx_m_axis_tdata        ),
      .user_rx_m_axis_tlast            ( user_rx_m_axis_tlast        ),
      .user_rx_m_axis_tuser            ( user_rx_m_axis_tuser        ),
      .i_gmii_rxdata                   ( gmii_rxdata                 ),
      .i_gmii_rxvalid                  ( gmii_rxvalid                ),
      .o_gmii_txdata                   ( gmii_txdata                 ),
      .o_gmii_txvalid                  ( gmii_txvalid                )
   );


endmodule